package com.eece411.project.p2;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ES {
	// Scheduler for multithreading in a Singleton
	private final ExecutorService es = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()*3);
	private ES() {	}
	private static class SingletonHolder { 
		public static final ES INSTANCE = new ES();
	}
	// The method to do command to the datastore
	public static ES getInstance() {
		return SingletonHolder.INSTANCE;
	}
	// ---- interface to the scheduler
	public void execute(Runnable r1){
		es.execute(r1);
	}
	public boolean isTerminated(){
		return es.isTerminated();
	}
	public void shutdown(){
		es.shutdown();
	}
	public boolean isShutdown(){
		return es.isShutdown();
	}
}
